import 'dart:convert';

import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../../utils/navigation_util.dart';
import '../datasources/room_list_repository_impl.dart';
import '../entity/room_bean.dart';
import '../intent/RoomListState.dart';

class RoomListViewModel extends StateNotifier<RoomListState> {
  final RoomListRepositoryImpl repositoryImpl;

  RoomListViewModel(this.repositoryImpl) : super(RoomListState());

  ///初始化数据的方法
  Future<void> initData() async {
    final roomList = await repositoryImpl.getDataForNet();
    state = state.copyWith(roomList: roomList);
  }

  ///跳转到下个页面
  void goNextPage(RoomBean data) {
    String json = jsonEncode(data.toJson());
    navigationUtil.goVideoTagPage(json);
  }
}
